{% extends 'base.html' %}

{% block content %}
<body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">

                    <div class="layui-form-item">
                        <button class="layui-btn layui-btn-normal" lay-filter="edit" lay-submit="" style="margin-top: 2%;">保存设置</button>
                    </div>

                    <div class="layui-form-item">
                            <textarea name="cookies" required lay-verify="cookies"  class="layui-textarea" style="height: 400px;">{{old_cookies}}</textarea>
                    </div>
                </form>
            </div>
        </div>
        <script>
            layui.use(['form', 'layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;

                //自定义验证规则
                form.verify({

                    cookies: [/\S/,'Cookies不能为空'],
                });

                //监听提交
                form.on('submit()',
                function(data) {
                    //console.log(data);
                    $.post(data.form.action,data.field);
                    //发异步
                    layer.alert("设置成功", {
                        icon: 6
                    },
                    function() {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        
                        //关闭当前frame
                        parent.layer.close(index);
                        
                        // 可以对父窗口进行刷新
                        xadmin.father_reload();
                    });
                    return false;
                });

            });
        </script>
    </body>
{% endblock %}